//
//  oldOrderPayViewController.m
//  laonianbang
//
//  Created by 勇拓 李 on 18/3/14.
//  Copyright © 2018年 zaiyou. All rights reserved.
//

#import "oldOrderPayViewController.h"
#import "oldPayView.h"
#import "oldEvaluateViewController.h"

@interface oldOrderPayViewController ()<oldPayViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *label_charge;
@property (weak, nonatomic) IBOutlet UILabel *label_type;
@property (weak, nonatomic) IBOutlet UILabel *label_time;
@property (weak, nonatomic) IBOutlet UILabel *label_price;
@property (weak, nonatomic) IBOutlet UIButton *btn_confirm;
@property (weak, nonatomic) IBOutlet UIButton *btn_question;

@end

@implementation oldOrderPayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
    [self initData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - initView
- (void)initView
{
    self.navigationItem.title = @"支付";
    
    _btn_confirm.layer.cornerRadius = 6.f;
    [_btn_confirm addTarget:self action:@selector(btn_confirm_tapped:) forControlEvents:UIControlEventTouchDown];
}

#pragma mark - initData
- (void)initData
{
    _label_time.text = [NSString stringWithFormat:@"服务时间：%@", _orderInfo.costTime];
    _label_type.text = [NSString stringWithFormat:@"服务类型：%@", _orderInfo.serveCategory.cname];
    _label_price.text = [NSString stringWithFormat:@"服务单价：¥%@", _orderInfo.serveCategory.price];
    _label_charge.text = _orderInfo.totalAmount;
}

#pragma mark - func
- (void)btn_confirm_tapped:(id)sender
{
    oldPayView *view = [[[NSBundle mainBundle] loadNibNamed:@"oldPayView"
                                                      owner:self
                                                    options:nil] objectAtIndex:0];
    view.orderInfo = _orderInfo;
    view.delegate = self;
}

#pragma mark - delegate
- (void)paySuccess
{
    oldEvaluateViewController *vc = [oldEvaluateViewController new];
    vc.orderInfo = _orderInfo;
    UINavigationController *nvi = [[UINavigationController alloc]initWithRootViewController:vc];
    
    [self presentViewController:nvi animated:YES completion:^{
        [self.navigationController popToRootViewControllerAnimated:YES];
    }];
}

@end
